<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>双向链表</title>
</head>

<body>
    <script type="module">
        import { DoublyLinkedList } from '../structure/linked_list/doubly_linked_list.js'

        const linkedList = new DoublyLinkedList()

        linkedList.append('aaa')
        linkedList.append('bbb')
        linkedList.append('ccc')
        linkedList.append('ddd')

        console.log('正向遍历:', linkedList.forwardString())
        console.log('反向遍历:', linkedList.reverseString())

        // 插入
        linkedList.insert(1, 'insert At 1')
        linkedList.insert(3, 'insert At 3')
        linkedList.insert(0, 'insert At 0')
        console.log('插入之后的正向遍历:', linkedList.forwardString())
        // console.log('当前链表', linkedList)

        console.log('get 1:', linkedList.get(1))
        console.log('indexOf:', linkedList.indexOf('insert At 0'))

        console.log('删掉3:', linkedList.removeAt(3))

        // update
        console.log('更新前链表:', linkedList.forwardString())
        linkedList.update(1, 'update!')
        console.log('更新后链表:', linkedList.forwardString())

        // remove
        linkedList.remove('update!')
        console.log('删除后链表:', linkedList.forwardString())
    </script>
</body>

</html>